/** Concrete implementation of the Filter interface
 *  used to filter Property objects from a Repository
 *
 *  @author Scott Monahan
 *  @version $Id$
 *  
 *  File last changed on $Date:$ by $Author:$ in $Rev:$
 *
 */

package info637.pprc.repository;

import info637.pprc.model.Property;

public class AdminPropertyFilter extends AbstractPropertyFilter {

	public AdminPropertyFilter(Property property) {
		
		super(property);
	}

	public boolean matches(Property in) {

		boolean retVal = true;
		
		if (this.property.getPropertyName() != null && this.property.getPropertyName().length() > 0) {
			
			if (!in.getPropertyName().contains(this.property.getPropertyName())) {
				
				retVal = false;
			}
		}
		
		if (retVal && (this.property.getTenantName() != null && this.property.getTenantName().length() > 0)) {
			
			if (!in.getTenantName().contains(this.property.getTenantName())) {
				
				retVal = false;
			}
		}
		
		if (retVal && (this.property.getBalance() != null && this.property.getBalance().length() > 0)) {
			
			Long searchBalance = Long.parseLong(this.property.getBalance());
			Long balance = Long.parseLong(in.getBalance());
			
			if (searchBalance >= balance) {
				
				retVal = false;
			}
		}
		
		return retVal;
	}
}
